<template>
  <div class="message">
    <ul class="msg" v-if="token" ref="msg">
      <li class="msg-list" v-for="(item,index) in msgData" :key="index">
        <p>
          <span class="title">{{item.name}}</span>
          <span class="time">{{item.currentTime|dTimer}}</span>
          <span class="lou">{{index+1}}楼</span>
        </p>
        <div class="msg-info" v-html="item.msg"></div>
      </li>
    </ul>
    <p v-else class="is-login">
      登录后才可以参与评论呦!!
      <button @click="$router.push('/auth/login')">去登录</button>
    </p>
  </div>
</template>

<script>
export default {
  props: ["mId", "token"],
  data() {
    return {
      msgData: []
    };
  },
  created() {
    this.getData();
  },
  methods: {
    getData() {
      this.$axios
        .post("/finddetailmsg", this.mId)
        .then(res => {
          console.log(res.data);
          this.msgData = res.data;
        });
    }
  }
};
</script>

<style lang="less" scoped>
.message {
  .is-login {
    text-align: center;
    margin: 50px 0 30px;
    button {
      display: inline-block;
      height: 38px;
      line-height: 38px;
      padding: 0 18px;
      background-color: #009688;
      color: #fff;
      white-space: nowrap;
      text-align: center;
      font-size: 14px;
      border: none;
      border-radius: 2px;
      cursor: pointer;
      transition: 0.5s;
    }
  }
  .msg {
    box-sizing: border-box;
    background: white;
    padding: 40px 0;
    // height:100%;
    width: 100%;
    .msg-list {
      background: rgb(238, 238, 238);
      height: 150px;
      border-radius: 5px;
      margin-bottom: 10px;
      p {
        .title {
          display: inline-block;
          width: 50px;
          height: 50px;
          background: blue;
          border-radius: 50%;
          line-height: 50px;
          text-align: center;
          margin-right: 30px;
        }
        .time {
          color: #aaa;
          font-size: 13px;
        }
        .lou {
          float: right;
          margin: 20px 50px 0 0;
        }
      }
      .msg-info {
        box-sizing: border-box;
        width: 90%;
        background-color: white;
        margin: 20px 0 20px 58px;
        padding: 10px;
        min-height: 50px;
        border-radius: 5px;
        font-size: 15px;
        color: #515250;
      }
    }
  }
}
</style>